/**
 * Copyright (c) 2016-2019 九点科技 All rights reserved.
 *
 * http://www.9dyun.cn
 *
 * 版权所有，侵权必究！
 */
package com.dian.modules.sale.controller;

import java.util.List;
import java.util.Map;

import com.dian.common.annotation.SysLog;
import com.dian.modules.sale.vo.ProbHeadExportVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.dian.common.controller.AbstractController;
import com.dian.modules.sale.entity.ProbHeadEntity;
import com.dian.modules.sale.service.ProbHeadService;
import com.dian.common.utils.PageUtils;
import com.dian.common.utils.R;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 预订单
 *
 * @author xiaolai
 * @email xiaolai@9dyun.cn
 * @date 2019-06-10 23:04:30
 */
@RestController
@Api("预订单接口")
@RequestMapping("sale/probHead")
public class ProbHeadController extends AbstractController{
    @Autowired
    private ProbHeadService probHeadService;


    /**
     * 预订单列表
     */
    @SysLog("预订单列表")
    @GetMapping("/list")
    @ApiOperation("预订单列表")
    @RequiresPermissions("sale:probHead:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = probHeadService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 预订单信息
     */
    @SysLog("预订单信息")
    @ApiOperation("预订单信息")
    @GetMapping("/info/{id}")
    @RequiresPermissions("sale:probHead:info")
    public R info(@PathVariable("id") Long id){
		ProbHeadEntity probHead = probHeadService.getInfo(id);

        return R.ok().put(probHead);
    }

    /**
     * 预订单保存
     */
    @SysLog("预订单保存")
    @ApiOperation("预订单保存")
    @PostMapping("/save")
    @RequiresPermissions("sale:probHead:save")
    public R save(@RequestBody ProbHeadEntity probHead){

		probHeadService.saveInfo(probHead);

        return R.ok();
    }

    /**
     * 预订单修改
     */
    @SysLog("预订单修改")
    @ApiOperation("预订单修改")
    @PostMapping("/update")
    @RequiresPermissions("sale:probHead:update")
    public R update(@RequestBody ProbHeadEntity probHead){

		probHeadService.updateInfo(probHead);

        return R.ok();
    }

    /**
     * 预订单删除
     */
    @SysLog("预订单删除")
    @ApiOperation("预订单删除")
    @GetMapping("/delete/{id}")
    @RequiresPermissions("sale:probHead:delete")
    public R delete(@PathVariable("id") Long id){
		probHeadService.deleteInfo(id);

        return R.ok();
    }

    /**
     * 预订单审核
     */
    @SysLog("预订单审核")
    @ApiOperation("预订单审核")
    @GetMapping("/check/{id}")
    @RequiresPermissions("sale:probHead:check")
    public R check(@PathVariable("id") Long id){

        probHeadService.checkInfo(id);
        return R.ok();
    }

    /**
     * 预订单导出
     */
    @SysLog("预订单导出")
    @ApiOperation("预订单导出")
    @GetMapping("/export")
    @RequiresPermissions("sale:probHead:export")
    public void export(@RequestParam Map<String, Object> params){
        List<ProbHeadExportVO> list = probHeadService.exportList(params);
        exportExcel(list,"预订单","预订单",ProbHeadExportVO.class,"预订单.xls");
    }


}
